//
//  photoViewController.m
//  HuiWenMovie
//
//  Created by niceDay on 15/7/23.
//  Copyright (c) 2015年 computer. All rights reserved.
//

#import "photoViewController.h"
#import "common.h"

@interface photoViewController ()

@end

@implementation photoViewController





- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self _createNavBar];
    [self _createCollectionView];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenAction) name:@"HiddenNavidationBar" object:nil];
    // Do any additional setup after loading the view.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
     

- (void)hiddenAction{
    BOOL isHidden = self.navigationController.navigationBar.isHidden;
    [self.navigationController setNavigationBarHidden:!isHidden animated:YES];
    
}

- (void)_createCollectionView{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  //  layout.itemSize = CGSizeMake(Kwidth, Kheight-64);
    layout.itemSize = self.view.bounds.size;
    layout.minimumInteritemSpacing = 0;
    layout.minimumLineSpacing = 0;
    layout.scrollDirection =   UICollectionViewScrollDirectionHorizontal;
    _collectionView = [[photoCollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
    _collectionView.pagingEnabled = YES;
    _collectionView.contentMode =   UIViewContentModeScaleAspectFill;
    [self.view addSubview:_collectionView];
}

- (void)setImageUrlArray:(NSMutableArray *)imageUrlArray{
    _imageUrlArray = imageUrlArray;
    _collectionView.imageUrlArray = _imageUrlArray;
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_currentIndex inSection:0];
    [_collectionView scrollToItemAtIndexPath:indexPath atScrollPosition: UICollectionViewScrollPositionLeft   animated:YES];
}
- (void)_createNavBar{
    self.navigationController.navigationBar.translucent = YES;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancleAction)];
    
}

- (void)cancleAction{
    [self dismissViewControllerAnimated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
